<template>
  <div>
    <h4>热门搜索</h4>
    <van-tag
      size="medium"
      type="primary"
      color="#eee"
      v-for="(item, index) in hotwordList"
      :key="index"
      @click="jumpTo(item.keyword)"
    >
      {{ item.keyword }}
    </van-tag>
  </div>
</template>

<script>
import Vue from "vue";
import { Tag ,Toast} from "vant";

import {search} from "../../apis/search"

import { gethotword} from "../../apis/search";
Vue.use(Tag);
Vue.use(Toast);

export default {
  name: "SearchMain",

  data() {
    return {
      hotwordList: [],
      value: "",
    };
  },

  mounted() {},

  methods: {
    jumpTo(value) {
      this.value = value;
      // localStorage.setItem("value",this.value)
      this.$router.push("/Searchlist/" + this.value);

      search({
        count: 1,
        limitNum: 12,
        keyword: this.$route.params.keyword,
      }).then((res) => {
        switch (res.data.code) {
          case "10002":
            Toast.fail("抱歉，暂未找到相关的商品");
            break;
          case "200":
            this.searchList = res.data.data;
            break;

          default:
            break;
        }
        // console.log(res.data);
      });
    },
  },

  created() {
    gethotword().then((data) => {
      this.hotwordList = data.data.data;
      //   console.log(data.data.data.wordid);
    });
  },
};
</script>

<style scoped>
div {
  background: #fff;
  min-height: 0.8rem;
  border-top: 0.02rem solid #999;
  padding: 0.1rem;
}
h4 {
  margin-bottom: 0.1rem;
}
.van-tag {
  color: #000;
  height: 0.3rem;
  line-height: 0.3rem;
  font-size: 0.16rem;
  margin: 0.1rem;
}
</style>